package cn.nexd.collector.bean;

import android.bluetooth.BluetoothDevice;

import java.util.List;

/**
 * Created by codngfish on 16/5/17.
 */
public class BeaconScannerResultStory {

    private final CollectorStoryContext collectorStoryContext;

    public synchronized List<BeaconScannerResult> getBeaconScannerResults() {
        //        List<BeaconScannerResult> beaconScannerResults = new ArrayList<>();
        //        for (Map.Entry<String, BeaconScannerResult> entry : map.entrySet()) {
        //            beaconScannerResults.add(entry.getValue());
        //        }
        //        clearBeaconScannerResult();
        //        return beaconScannerResults;
        return collectorStoryContext.getBeaconScannerResults();
    }


    public BeaconScannerResultStory() {
        collectorStoryContext = new CollectorStoryContext(new DefaultBeaconStoryStrategy());
    }

    public synchronized void clearBeaconScannerResult() {
        collectorStoryContext.clear();
    }

    // http://kittensandcode.blogspot.com/2014/08/ibeacons-and-android-parsing-uuid-major.html
    public synchronized void addBeaconScannerResult(BluetoothDevice device, int rssi, byte[] scanRecord, long timestamp) {

        collectorStoryContext.process(device, rssi, scanRecord, timestamp);


    }
}
